package com.itqf.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Description:  swagger2(现在api文档) 的配置类
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2020/10/13
 * @Time: 上午11:05
 */
@Configuration //Spring的配置文件  applicationContext-swagger.xml
@EnableSwagger2  // 开启swagger   http://localhost:8089/swagger-ui.html
public class SwaggerConfig {

    //创建了 Docket   对象
    @Bean
    public Docket getDocket(){

        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .useDefaultResponseMessages(false)
                .select()
                //.paths(Predicates.or(PathSelectors.regex("/api2/.*")))//  过滤  该路径下的请求生成RESTful api
                .build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("小米商城")//大标题
                .description("小米商城 Platform's REST API, all the applications could access the Object model data via JSON.")//详细描述
                .version("2.0")//版本
                .contact(new Contact("java", "http://itqf.com", "123456@qq.com"))//作者
                .license("The Apache License, Version 2.0")//许可证信息
                .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")//许可证地址
                .build();

    }



}
